
const state = {
  systemLogs: [], // 系统消息
  unreadLogNum: 0, // 未读数量
  businessLogs: [], // 业务消息
  businessUnreadNum: 0, // 业务未读消息
}

const mutations = {
  // ------------------------- 系统消息 -------------------------
  // 清除消息列表
  CLEAR_SYSTEM_LOG: (state) => {
    state.systemLogs.splice(0)
    state.unreadLogNum = 0
  },
  // 新增消息
  ADD_SYSTEM_LOG: (state, log) => {
    state.systemLogs.push(log)
    state.unreadLogNum ++
    if(state.systemLogs.length > 200) {
      state.systemLogs.shift()
    }
  },
  // 重置未读数量
  CLEAR_UNREAD_LOG_NUM: (state) => {
    state.unreadLogNum = 0
  },
  // ------------------------- 业务消息 ------------------
  CLEAR_BUSINESS_LOG: (state) => {
    state.businessLogs.splice(0)
    state.businessUnreadNum = 0
  },
  ADD_BUSINESS_LOG: (state, log) => {
    state.businessLogs.push(log)
    state.businessUnreadNum ++
    if(state.businessLogs.length > 200) {
      state.businessLogs.shift()
    }
  },
  CLEAR_BUSINESS_UNREAD_NUM: (state) => {
    state.businessUnreadNum = 0
  }
}

const actions = {

}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
